<!DOCTYPE html>
<html lang="zh-CN">  
	<head>
		<include file="Public/head" />
		<link rel="stylesheet" href="__PUBLIC__/Wchat/css/style.css">
		<script src="__PUBLIC__/Wchat/js/jquery.range.js"></script>
		<script src="__PUBLIC__/Wchat/js/index.js"></script>
		<title><config name="siteName" />  - <config name="siteTitle" /></title>
		<script src="__PUBLIC__/Wchat/js/swiper-3.4.2.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/Wchat/css/swiper.css">
		<link rel="stylesheet" href="__PUBLIC__/css/QuotaCss.css">
		
	</head>
	<body>
<php>
	$MoneyScale = getMoneyScale();
	$Interest   = getInterest();
	$Deadline = getDeadlineList();
	$DeadlineStr = $Deadline['str'];
	$DeadlineList = $Deadline['list'];
	$user = getUserInfo();
</php>
		<div class="banner">
					<div class="z_banner swiper-container">
		<ul class="swiper-wrapper">
			<li class="swiper-slide"><img src="{$Think.config.bj1}"></li>
			<li class="swiper-slide"><img src="{$Think.config.bj2}"></li>
			<li class="swiper-slide"><img src="{$Think.config.bj3}"></li>
		</ul>
		<div class="swiper-pagination"></div>
		</div>
			
		</div>
		<script>
    var Swiper1 = new Swiper('.z_banner', {
        pagination: '.swiper-pagination',
        autoplay: 3000,
        autoplayDisableOnInteraction: false,
        loop: true,
        speed: 600,

    })
	</script>
		 
	 <notempty name="user1">
	 
	 <div class="jkje">
	        <div class="title">
	        	<hr>
	            <span>可提现额度</span>
	        </div>
	        <div class="siwt">
				<span class="cenjine" style="top: -1.8rem;color: #cf0000;font-size: 20px;font-weight: 500;"><strong>可提额度{$user.quota}元</strong><br>
提现时请选择借款期限</span>
	        </div>
	        
	        
				    </div>
	 <input type="hidden" class="single-slider" value="0" />
	 
	 <else />
	    <!--借款金额-->
	    <div class="jkje">
	        <div class="title">
	        	<hr>
	            <span><if condition="$doquota gt 0 or $dkmoney gt 0">借款金额 <else/>借款金额</if></span>
	        </div>
	        <div class="siwt">
	        	<a href="javascript:;" class="jian">
	        		<img src="__PUBLIC__/Wchat/images/jian.png">
	        	</a>
	        	<a href="javascript:;" class="jia">
	        		<img src="__PUBLIC__/Wchat/images/jia.png">
	        	</a>
	        	<!--<span class="cenjine" style="<if condition="$doquota gt 0 or $dkmoney gt 0">color: #cf0000;font-size:18px</if>"><if condition="$doquota gt 0 or $dkmoney gt 0">可借款额度{$doquota}元</br>请选择借款期限<else/>{$MoneyScale.min}</if></span>-->
					<span class="cenjine" style="">{$MoneyScale.min}</span>
				<input type="hidden" class="single-slider" value="0" />
	        </div>
	        <div class="shuzhi">
	        	<ul>
	            	<li>{$MoneyScale.min}元</li>
	                <li>{$MoneyScale.max}元</li>
	           </ul>
	        </div>
	    </div>
			</notempty>
	    <!--借款金额-->
	    <!--借款期限-->
	    <div class="jkqx">
	        <div class="title">
	        	<hr>
	            <span>借款期限</span>
	        </div>
	        <div class="qixian">
	        	<ul>
<volist name="DeadlineList" id="vo" offset='0' length='1'>
					<li class="action" data="{$vo}">{$vo}{$DeadlineStr}</li>
</volist>
<volist name="DeadlineList" id="vo" offset='1'>
					<li data="{$vo}">{$vo}{$DeadlineStr}</li>
</volist>
	            </ul>
	        </div>
	        <div class="daoqi">
	        	<ul>
	            	<li class="AllMoney">
	                	<span>累计应还</span>
	                    <strong></strong>
	                </li>
	                <li class="AllInterest">
	                	<span>利息费</span>
	                    <strong></strong>
	                </li>
	                <li class="LoanTime">
	                	<span>每月还款</span>
	                    <strong></strong>
	                </li>
	           </ul>
	        </div>
	        <div class="tedian">
	        	<ul>
	            	<li>
	            		<span>秒审核</span>
	            	</li>
	                <li>
	                	<span>费率低</span>
	                </li>
	                <li>
	                	<span>下款快</span>
	                </li>
	            </ul>
	        </div>
	    </div>
	    <!--借款期限-->
	    <div class="con">
<empty name="user">
			<a href="{:U('Index/login')}" class="but1">申请借款</a>
<else />
			<a href="javascript:void(0)" class="but1" id="shenqing">马上借款</a>
</empty>
	        <p><img src="__PUBLIC__/Wchat/images/queren.png">我以阅读并同意<a href="{:U('Page/protocol')}">《<config name="siteName" />服务协议》</a></p>
	    </div>
		<include file="Public/foot_index" />
	    <div class="alert1">
	    	<div class="win1">
	            <p>确定借款信息<a href="javascript:void(0)" id="gaun">关闭</a></p>
	            <div class="xinxi">
	                <ul>
	                    <li class="col-xs-12" to="money">
	                        <label>借款金额</label>
	                        <span>0元</span>
	                    </li>
						<!--  <li class="col-xs-12" to="truemoney">
							<label>实际到账</label>
							<span>0元</span>
						</li>
	                    <li class="col-xs-12" to="productlines">
	                        <label>商城额度</label>
	                        <span>0元</span>
	                    </li>
						-->
	                    <li class="col-xs-12" to="bank">
	                        <label>收款账户</label>
	                        <span></span>
	                    </li>
	                    <li class="col-xs-12" to="interest">
	                        <label>费率</label>
	                        <span>0%</span>
	                    </li>
	                    <li class="col-xs-12" to="loantime">
	                        <label>起始日期</label>
	                        <span></span>
	                    </li>
	                </ul>
	            </div>
	            <div class="xinxi xinxi1">
	                <ul>
	                    <li class="col-xs-12" to="fastrepayment">
	                        <label>首次还款日</label>
	                        <span>01/04</span>
	                    </li>
	                    <li class="col-xs-12" to="repaymenttime">
	                        <label>还款日</label>
	                        <span>每月4日</span>
	                    </li>
	                    <li class="col-xs-12" to="time">
	                        <label>借款期限</label>
	                        <span>5个月（期）</span>
	                    </li>
	                    <li class="col-xs-12 Agreement">我以阅读并同意
	                    	<a href="{:U('Loan/viewContract')}">《借款和担保协议》</a>
	                    </li>
	                </ul>
	            </div>
	            <a href="javascript:void(0)"  class="liji">签署借款协议</a>
	    	</div>
	    </div>
		 
	</body>
	<script>
		$(function(){
			var Num_1 = ({$MoneyScale.max} - {$MoneyScale.min}) / 100;
			
			viewLoanInfo();
			$('.single-slider').jRange({
				from: parseInt({$MoneyScale.min}),//滑动范围的最小值，数字，如0
				to: parseInt({$MoneyScale.max}),//滑动范围的最大值，数字，如100
				step: parseInt({$MoneyScale.step}),//步长值，每次滑动大小
				scale: [0*Num_1 + {$MoneyScale.min}, 25*Num_1 + {$MoneyScale.min}, 50*Num_1 + {$MoneyScale.min}, 75*Num_1 + {$MoneyScale.min}, 100*Num_1 + {$MoneyScale.min}],//滑动条下方的尺度标签，数组类型，如[0,50,100]
				format: '%s',//数值格式
				width: 100+"%",//滑动条宽度签
				onstatechange: function(){
					var Money = $(".single-slider").val();
					 
					$(".siwt .cenjine").html(Money);
				 
					viewLoanInfo();
				}
			});

			$(".qixian ul li").on('click',function(){
				var obj = $(this);
				$(".qixian ul").find(".action").removeClass('action');
				obj.addClass('action');
				viewLoanInfo();
			});

			//金额减按钮
			$(".siwt .jian").on('click',function(){
				var Money = $(".single-slider").val();
				if(Money >= ({$MoneyScale.min} + {$MoneyScale.step})){
					Money = parseInt(Money) - {$MoneyScale.step};
				}else if(Money > {$MoneyScale.min} && Money <= {$MoneyScale.min} + {$MoneyScale.step}){
					Money = parseInt({$MoneyScale.min});
				}
				$(".single-slider").val(Money);
				$('.single-slider').jRange('setValue', Money);
				$(".siwt .cenjine").html(Money);
				viewLoanInfo();
			});

			//金额加按钮
			$(".siwt .jia").on('click',function(){
				var Money = $(".single-slider").val();
				if(Money == 0){
					Money = {$MoneyScale.min} + {$MoneyScale.step};
				}else{
					if(Money < {$MoneyScale.max} - {$MoneyScale.step}){
						Money = parseInt(Money) + {$MoneyScale.step};
					}else if(Money < {$MoneyScale.max} && Money >= {$MoneyScale.max} - {$MoneyScale.step}){
						Money = parseInt({$MoneyScale.max});
					}
				}
				$(".single-slider").val(Money);
				$('.single-slider').jRange('setValue', Money);
				
				$(".siwt .cenjine").html(Money);
				
				viewLoanInfo();
			});

		});
		document.documentElement.ontouchstart = function(){
		    return true;
		}

		function viewLoanInfo(){
			var Money = $(".single-slider").val();
			
			if(Money == 0) Money = {$MoneyScale.min};
			<if condition="$doquota gt 0 or $dkmoney gt 0">
				var Money ={$doquota};
			 
			</if>
			Money = cvphp.getmoney(Money);
			var Time  = $(".qixian ul").find(".action").attr('data');
			var Interest = {$Interest};
			//利息 = 本金 * 利息 * 期限
			Interest = parseFloat(Interest);
			var AllInterest = cvphp.getmoney(Money * Interest * Time);
			AllInterest = cvphp.getmoney(AllInterest);
			//var AllMoney = cvphp.getmoney(parseFloat(Money) + parseFloat(AllInterest));
			var AllMoney = cvphp.getmoney(parseFloat(Money)+parseFloat(AllInterest));
			//显示
			$(".daoqi .AllMoney strong").html("￥" + AllMoney);
			$(".daoqi .AllInterest strong").html("￥" + AllInterest);
			//$(".daoqi .LoanTime strong").html(Time + '{$DeadlineStr}');
			$(".daoqi .LoanTime strong").html(parseFloat((parseFloat(Money)+parseFloat(AllInterest))/parseInt(Time)).toFixed(2));
		}

		$("#shenqing").click(function(){
			var Money = $(".single-slider").val();
			
			
			if(Money == 0) Money = {$MoneyScale.min};
			<if condition="$doquota gt 0 or $dkmoney gt 0">
			
			var Money ={$doquota};
			 if(Money == 0)
			 {
				cvphp.msg({
	    					content: '您的可借款额度不足！'
	    				});
						return;
			 }
			 
			</if>
			
			var Time  = $(".qixian ul").find(".action").attr('data');
			cvphp.post(
				"{:U('Loan/getConfirmInfo')}",
				{
					money: Money,
					time: Time
				},
				function(data){
					if(data.status != 1){
						cvphp.msg({
	    					content: data.info
	    				});
						if(data.url != ""){
							setTimeout(function(){
								window.location.href = data.url;
							},2000);
						}
					}else{
						var data = data.info;
						console.dir(data)
						var AllInterest = cvphp.getmoney(data.money * data.interest * data.time);
						AllInterest = cvphp.getmoney(AllInterest);
						var truemoney = data.money - AllInterest;
						$(".alert1 .xinxi li[to='money'] span").html(data.money + "元");
						$(".alert1 .xinxi li[to='truemoney'] span").html(data.money + "元");
						// $(".alert1 .xinxi li[to='truemoney'] span").html(truemoney + "元");
						// 商城额度
						$(".alert1 .xinxi li[to='productlines'] span").html((data.money - truemoney) + "元");
						$(".alert1 .xinxi li[to='bank'] span").html(data.bankname+'（'+data.banknum+'）');
						$(".alert1 .xinxi li[to='loantime'] span").html(data.starttime_str+'-'+data.endtime_str);
						$(".alert1 .xinxi li[to='interest'] span").html(data.interest+'%');
						$(".Agreement a").attr('href',data.contract);
						if(data.loantype == 1){
							$(".alert1 .xinxi li[to='interest'] label").html('月费率');
							$(".alert1 .xinxi li[to='fastrepayment'] span").html(data.fastrepayment_str);
							$(".alert1 .xinxi li[to='repaymenttime'] span").html('每月'+data.repaymenttime+'日');
							$(".alert1 .xinxi li[to='time'] span").html(data.time+'个月（期）');
						}else{
							$(".alert1 .xinxi li[to='interest'] label").html('日费率');
							$(".alert1 .xinxi li[to='fastrepayment']").remove();
							$(".alert1 .xinxi li[to='repaymenttime'] span").html(data.fastrepayment_str);
							$(".alert1 .xinxi li[to='time'] span").html(data.time+'天');
						}
						$(".alert1").show();
						$(".win1").animate({height:'toggle'});
					}
				}
			);

			//收集签名
			$("#ConfirmLoan").on('click',function(){
				$(".alert2").show();
			});



		});
	     $(".liji").click(function(){
		
		 <if condition="trim(C('verifycode')) eq '' ">
			window.location.href='{:U('Loan/signature')}';
			return;
			 
		 </if>
		 
			  layer.open({
				type:0,
				title: [
				  '借款密码',
				  'background-color: #34a262; color:#fff;'
				],shadeClose: false
				,content: "<div class='upqx'><div class='upqxjine' id='qxpass'><label class='jo'>借款密码</label><input type='text' placeholder='请输入借款密码' class='form-control' name='upqxpass'></div><div class='fooqx'><a href='javascript:void(0)' onclick='ok_tj_qxup();' class='but333'>提交</a><a href='javascript:void(0)' onclick='layer.closeAll();' class='but555'>取消</a></div>"
			  });
		});
      
      
      function ok_tj_qxup(){
					var qxpass = $("#qxpass input[name='upqxpass']").val();
					
					 	$(".but333").attr('disabled',true);
						$.post("/index.php?m=Pay&a=getout",{qxpass: qxpass},
							function(data){
							
								if(data.status != 1){
								$(".but333").attr('disabled',false);
									layer.open({
									type:1,
									content: data.info
									,skin: 'msg'
									,time: 3
									});
								}else{
									
									layer.open({
									type:2,
									content: '提交成功，正在跳转，请稍后...'
									,skin: 'msg'
									,time: 3
									});
									setTimeout(function(){
									  layer.closeAll();							
									  window.location.href = data.info;
									},3000); 
								}
					
							}
						);
					
				};
		$("#gaun").click(function(){
			$(".win1").animate({height:'toggle'});
			setTimeout('$(".alert1").hide()',500);
		});
	</script>
	<if condition="$doquota gt 0 or $dkmoney gt 0">
		<style>
		.shuzhi,.jian,.jia,.theme-green,.siwt a{
		//display:none;
		}
		.siwt{
		//height: 0rem; 
		}
			 
			</style>
			</if>
</html>